<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="../back-common.jsp"%>
<%@ include file="/WEB-INF/pages/common/taglib.jsp"%>
<script src="${contextPath}/resources/common/js/jquery.validate.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" media="screen" href="${contextPath}/resources/common/css/errorform.css" />
<script src="<ls:templateResource item='/resources/plugins/My97DatePicker/WdatePicker.js'/>" type="text/javascript"></script>
<link rel="stylesheet" href="<ls:templateResource item='/resources/plugins/kindeditor/themes/default/default.css'/>"/>
<link rel="stylesheet" href="<ls:templateResource item='/resources/plugins/kindeditor/plugins/code/prettify.css'/>"/>
<script charset="utf-8" src="<ls:templateResource item='/resources/plugins/kindeditor/kindeditor-min.js'/>"></script>
<script charset="utf-8" src="<ls:templateResource item='/resources/plugins/kindeditor/lang/zh_CN.js'/>"></script>
<script charset="utf-8" src="<ls:templateResource item='/resources/plugins/kindeditor/plugins/code/prettify.js'/>"></script>

<link href="<ls:templateResource item='/resources/plugins/select2-4.0/select2.css'/>" rel="stylesheet"/>
<script src="<ls:templateResource item='/resources/plugins/select2-4.0/select2.full.min.js'/>" type="text/javascript"></script>
<script src="<ls:templateResource item='/resources/plugins/select2-4.0/i18n/zh-CN.js'/>" type="text/javascript"></script>
<script src="<ls:templateResource item='/resources/plugins/select2-4.0/makeSelect2.js'/>" type="text/javascript"></script>
<table class="${tableclass}" style="width: 100%">
	   <tr><th><strong class="am-text-primary am-text-lg">项目管理</strong> /  
	    		<c:choose>
	                <c:when test="${not empty project}">修改项目</c:when>
	                	<c:otherwise>创建项目</c:otherwise>
	                </c:choose>
	    	</th></tr>
</table>

<div style="margin-left: 0.5rem">
    <div class="seller_list_title">
        <ul class="seller_title_ul am-tabs-nav am-nav am-nav-tabs">
            <li class="am-active"><i></i><a href="<ls:url address="/admin/project/load/${project.id}"/>">项目信息</a></li>
            <c:if test="${not empty project.id}">
            <li><i></i><a href="<ls:url address="/admin/projectPlan/query/${project.id}"/>">里程碑</a></li>
            <li><i></i><a href="<ls:url address="/admin/task/query/${project.id}"/>">目标</a></li>
            <li><i></i><a href="<ls:url address="/admin/projectModule/query/${project.id}"/>">模块</a></li>
            <li><i></i><a href="<ls:url address="/admin/projectMember/query/${project.id}"/>">团队</a></li>
            <li><i></i><a href="<ls:url address="/admin/projectReport/query/${project.id}"/>">报表</a></li>
            </c:if>
        </ul>
    </div>
</div>

<form action="<ls:url address='/admin/project/save'/>" method="post" id="form1">
	<input id="id" name="id" value="${project.id}" type="hidden">
		<table border="0" align="center" class="${tableclass}" id="col1">
			<tr>
				<td class="center_letter" width="230px;">
						项目名称: <font color="ff0000">*</font>
				</td>
				<td><input type="text" name="name" id="name" value="${project.name}" /></td>
			</tr>
			<tr>
				<td  class="center_letter" >
						项目别名: <font color="ff0000">*</font>
				</td>
				<td><input type="text" name="aliasName" id="aliasName" value="${project.aliasName}" /></td>
			</tr>
			<tr>
				<td class="center_letter">
						项目性质: <font color="ff0000">*</font>
				</td>
				<td>
				 <select id="type" name="type">
					<ls:optionGroup type="select" required="true" cache="true"
	                beanName="PROJECT_TYPE" selectedValue="${project.type}"/>
	             </select>  
	                   私有项目只有项目成员可以访问,公有项目全体成员都可以访问
	           </td>
			</tr>
			<tr>
				<td class="center_letter">
				计划时间
				</td>
				<td>
				     开始时间: 
					<input readonly="readonly"  name="startTime" id="startTime" class="Wdate" type="text" onClick="WdatePicker({dateFmt:'yyyy-MM-dd',onpicked:function(){endTime.focus();},maxDate:'#F{$dp.$D(\'endTime\')}'})" value='<fmt:formatDate value="${project.startTime}" pattern="yyyy-MM-dd"/>' />
					
					结束时间: 
					<input readonly="readonly" name="endTime" id="endTime" class="Wdate" type="text" onClick="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'startTime\')}'})" value='<fmt:formatDate value="${project.endTime}" pattern="yyyy-MM-dd"/>' />
				</td>
			</tr>
			<tr>
				<td class="center_letter">
						工时计划
				</td>
				<td>
				预估工时: 
				<input type="text" name="estimateHours" id="estimateHours" value="${project.estimateHours}" />
				<c:if test="${not empty project.actualHours}">
					 &nbsp; 实际消耗工时${project.actualHours}
				</c:if>
				</td>
			</tr>
			<tr>
				<td class="center_letter">
					每周最长时长
				</td>
				<td>
					<input type="text" name="maxHoursPerweek" id="maxHoursPerweek" value="${project.maxHoursPerweek}" />
				</td>
			</tr>
			<tr>
				<td class="center_letter">
						负责人: <font color="ff0000">*</font>
				</td>
				<td>
				&nbsp;项目经理&nbsp;
				   <select name="principal" id="principal" style="width: 200px">
				   <c:if test="${not empty project.principal}">
				   	  <option value="${project.principal}">${project.principalRealName}</option>
				   	</c:if>
				   </select>
				   
				&nbsp; 测试经理&nbsp;
				   <select name="tester" id="tester" style="width: 200px">
				  		<c:if test="${not empty project.tester}">
					   	  <option value="${project.tester}">${project.testerRealName}</option>
					   	</c:if>
				  </select>
				</td>
			</tr>
			<tr>
				<td class="center_letter">
						项目状态:
				</td>
				<td>
				 <select id="status" name="status">
					<ls:optionGroup type="select" required="true" cache="true"
	                beanName="PROJECT_STATUS" selectedValue="${project.status}"/>
	             </select>  
	           </td>
			</tr>
			<tr>
				<td class="center_letter">
						描述: 
				</td>
				<td>
				   <textarea name="remark" id="remark" cols="100" rows="8" style="width:700px;height:200px;visibility:hidden;">${project.remark}</textarea>
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<div align="center">
					<ls:auth ifAllGranted="M_EDIT_PROJECT">
						<input type="submit" value="提交" /> 
					</ls:auth>
						<input type="reset" value="重置" />
						 <input type="button" value="返回" onclick="window.location='<ls:url address="/admin/project/query"/>'" />
					</div>
				</td>
			</tr>
		</table>
</form>
  <script language="javascript">
	 $.validator.setDefaults({
   });

    $(document).ready(function() {
    jQuery("#form1").validate({
            rules: {
            name: {
                required: true,
                minlength: 2
            },
            aliasName: {
                required: true,
                minlength: 2
            },
            principal: "required",
			maxHoursPerweek: {
				required: true,
				range:[0,56],
				number:true
			}
        },
        messages: {
        	name: {
                required: "请输入名称",
                minlength: "名称最少输入长度为2个字符"
            },
            aliasName: {
                required: "请输入项目别名",
                minlength: "名称最少输入长度为2个字符"
            },
            principal: {
                required: "必填"
            },
			maxHoursPerweek:{
				required: "必填",
				range: "范围在0-56小时",
				number: "必须为数字"
			}
        }
    });
 
		//斑马条纹
     	 $("#col1 tr:nth-child(even)").addClass("even");
		
         KindEditor.options.filterMode = false;
         KindEditor.create('textarea[name="remark"]', {
             cssPath: '${contextPath}/resources/plugins/kindeditor/plugins/code/prettify.css',
             uploadJson: '${contextPath}/editor/uploadJson/upload;jsessionid=${cookie.JSESSIONID.value}',
             fileManagerJson: '${contextPath}/editor/uploadJson/fileManager',
             allowFileManager: true,
             afterBlur: function () {
                 this.sync();
             },
             width: '100%',
             height: '400px',
			 items : [
				 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
				 'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
				 'insertunorderedlist', '|', 'emoticons', 'link']
         });
         prettyPrint();
         
        makeSelect2(contextPath + "/admin/adminUser/userList","#principal","项目负责人","value","key");
         
        makeSelect2(contextPath + "/admin/adminUser/userList","#tester","测试负责人","value","key");
});
    

</script>
